package com.example.observe.gperadvice;

public class ObserveTest {
    public static void main(String[] args) {
        Question question = new Question();
        question.setUsername("小米");
        question.setContent("观察者模式到底怎么写？");

        GPer gPer = GPer.getInstance();

        // 添加需要观察的人
        Teacher tom = new Teacher();
        tom.setName("Tom");
        gPer.addObserver(tom);

        // 发布消息，观察的人才能收到消息
        gPer.publishQuestion(question);

    }
}
